<template>
  <div class="ipc">
    <el-card class="box-card">
      <el-row>
        <el-button @click="createErrorDialog">点击打开一个错误弹框</el-button>
        <el-button @click="createDialog">点击打开一个系统对话弹框</el-button>
        <el-button @click="createMessage">点击打开一个信息提示框</el-button>
        <el-button @click="createOpenDialog">点击打开一个文件选择框</el-button>
      </el-row>
      <el-row></el-row>
    </el-card>
  </div>
</template>
<script>
import { remote } from 'electron'
export default {
  methods: {
    createErrorDialog () {
      remote.dialog.showErrorBox('错误', '这是一个错误弹框！')
    },
    createDialog () {
      remote.dialog.showMessageBox({
        type: 'info',
        title: '提示信息',
        message: '这是一个对话弹框！',
        buttons: ['确定', '取消']
      }, (index) => {
        this.$message.error(`【你点击了${index ? '取消' : '确定'}！！】`)
      })
    },
    createMessage () {
      const options = {
        title: '信息框标题',
        body: '我是一条信息～～～'
      }
      // eslint-disable-next-line no-new
      new window.Notification(options.title, options)
      this.$message.error('【你点击了信息框！！】')
    },
    createOpenDialog () {
      remote.dialog.showOpenDialog({
        properties: ['openDirectory', 'openFile']
      }, (data) => {
        this.$message.error(`【选择路径：${data[0]}】 `)
      })
    }
  }
}
</script>
